package cn.wangyaying.util;

import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class MyFrame extends Frame {

	// 加载窗口

	public void launchFrame() {

		// 定义窗口大小

		setSize(Constant.GAME_HIGH, Constant.GAME_WIDTH);

		// 定义窗口位置

		setLocation(500, 30);

		// 定义窗口是可看见的

		setVisible(true);

		new PaintThread().start();// 启动重画线程

		// 增加个窗口监听

		addWindowListener(new WindowAdapter() {

			public void windowClosing(WindowEvent e) {

				System.exit(0);

			}

		});

	}
	

	/**
	 * 
	 *  * 定义一个重画窗口的线程类，是一个内部类
	 * 
	 *  * 
	 * 
	 *  * @param wangyaying
	 * 
	 *  
	 */

	class PaintThread extends Thread {

		public void run() {

			while (true) {

				repaint();

				try {

					Thread.sleep(40);

				} catch (InterruptedException e) {

					e.printStackTrace();

				}

			}

		}

	}

}
